// 开发环境服务器地址
let baseURL = 'http://api-breakingnews-web.itheima.net';
$.ajaxPrefilter(function (params) {
    params.url = baseURL + params.url;

    //身份认证
    if (params.url.indexOf("/my/") != -1) {
        params.headers = {
            Authorization: localStorage.getItem('token') || ""
        }
    }

    //拦截所有响应，判断身份认证信息
    params.complete = function (res) {
        // console.log(res.responseJSON);
        let obj = res.responseJSON;
        if (obj.status == 1 && obj.message == '身份认证失败！') {
            ///清空本地token
            localStorage.removeItem('token');

            // 页面跳转
            location.href = '/login.html';
        }
    }
})